package com.ofc.chart.builder;

import com.ofc.chart.engine.IChartJsonBuilder;
import com.ofc.chart.model.Line;

/**
 * Line Chart Json对象构建类
 * 
 * @author zhangpeng
 * @date 2012-12-6
 * 
 */
public class LineJsonBuilder implements IChartJsonBuilder {
	private ElementBuilder elementBuilder = new ElementBuilder();
	private Line line;

	@Override
	public String buildJson() {
		StringBuffer json = new StringBuffer("{");
		String titleJson = elementBuilder.buildTitle(line.getTitle());
		String ylegendJson = elementBuilder.buildYLegend(line.getYlegend());
		String xaxisJson = elementBuilder.buildXAxis(line.getXaxis());
		String yaxisJson = elementBuilder.buildYAxis(line.getYaxis());
		String elementsJson = elementBuilder.buildElements(line.getElements());
		json.append(titleJson + ",");
		json.append(ylegendJson + ",");
		json.append(xaxisJson + ",");
		json.append(yaxisJson + ",");
		json.append(elementsJson);
		json.append("}");
		return json.toString();
	}

	public LineJsonBuilder(Line line) {
		this.line = line;
	}
}
